package com.tria.hcu.dao.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tria.hcu.bean.Usuario;
import com.tria.hcu.dao.LoginDao;

public class LoginDaoImpl implements LoginDao{

	private Map<Long,Usuario> base = newMap(ENTRIES);
    //singletton patron muy importante! verlooo

    private static final Object[][] ENTRIES =
    	{
    	  {new Long(0),new Usuario("pepe", "123","error1")},
    	  {new Long(1),new Usuario("coco", "123","error2")},
    	  {new Long(2),new Usuario("juan", "123","error3")}
    	};

    @Override
    public Usuario getById(long id){
        return base.get(id);
    }
	
	@Override
	public List<Usuario> getAll() {
		return new ArrayList<Usuario>(base.values());
	}

	private static Map newMap(Object[][] entries)
	{
	  Map map = new HashMap();

	  for (int x = 0; x < entries.length; x++)
	  {
	    Object[] entry = entries[x];

	    map.put(entry[0], entry[1]);
	  }

	  return map;
	}
	
}
